﻿
@{
    ViewBag.Title = "用户注登录";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@section Header{
    <link href="~/Asset/CSS/member_style.css" rel="stylesheet" />
    <link href="~/Asset/CSS/public_style.css" rel="stylesheet" />
    <script src="~/Asset/param.js"></script>
}

        <div class="content">

            <div class="mem_login_all">
                <div class="mem_body loginlayout">
                    <div class="mem_login_pic fl">
                        <img src='~/Asset/login_pic.png' width="459" height="469" />
                    </div>
                    <div class="mem_login fr">
                        <div class="mem_login_title">
                            <h3>会员登录</h3>
                            <a href="javascript:;">手机验证码登录<span></span></a>
                        </div>
                        <div class="error_message" id="error" style="display: none"></div>
                        <ul>
                            <li>
                                <input type="text" id="HYZH" placeholder="用户名/手机号码" value="" maxlength="20" />
                            </li>
                            <li>
                                <input type="password" id="HYMM" placeholder="密码" maxlength="20" />
                            </li>
                            <!--登录密码错误三次以后显示验证码-->
                            @*<li style="display: none" id="yzmsfxs">
                                <input type="text" class="verifycode" id="code" placeholder="验证码" maxlength="8" />
                                <span>
                                    <img style="height: 35px; cursor: pointer" id="imgVerifyCode" title="看不清楚，请点击换一个。" onclick="refreshVerifyCode()" alt="" src="VerifyCode.ashx?" />
                                </span>

                            </li>*@
                            <li>
                                <label>
                                    <input type="checkbox" class="nologin" id="ck" />一周内免登录
                                </label>
                                <samp>
                                    <a href="/zc.html">新用户注册</a>
                                </samp>
                                <samp><a href="/mm1.html">忘记密码？</a></samp>

                            </li>
                            <li><em><a onclick="javascript:checkout();" id="btnLogin" style="cursor: pointer">登录</a></em></li>
                        </ul>

                        <ul style="display:none;">
                            <li><input type="text" placeholder="请输入手机号" id="phone" class="telnum onlynumber" maxlength="11" /></li>
                            <li><input type="text" id="code" class="verifycode onlynumber" placeholder="验证码" maxlength="6" /><span id="getCode" class="getvcode"><a href="javascript:;">获取验证码</a></span></li>
                            <li>
                                <label><input type="checkbox" class="nologin" />一周内免登录</label>
                                <samp>
                                    <a href="/zc.html">新用户注册</a>
                                </samp>
                                <samp><a href="/mm1.html">忘记密码？</a></samp>
                            </li>
                            <li><em><a id="phoneLogin" href="javascript:void(0)" onclick="Register();">登录</a></em></li>
                            <li><div id="msgNo" class="alert alert-danger" role="alert"></div></li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>

        <script>
            $(document).keydown(function (event) {
                if (event.keyCode == 13) {
                    if ($("#HYZH").is(":focus") || $("#HYMM").is(":focus") || $("#code").is(":focus")) {//如果输入框有焦点
                        $('#btnLogin').click();
                    }
                }
            });
        </script>

        <script type="text/javascript">
            var alltime = 60;
            $("ul").on("click", ".getvcode.active", function () {
                var phone = $.trim($("#telNum").val());
                getCode(phone);
                $this = $(this);
                $this.removeClass("active");

                var timer = setInterval(function () {
                    alltime--;
                    if (!alltime) {
                        clearInterval(timer);
                        alltime = 60;
                        $this.addClass("active");
                        $this.find("a").html("获取验证码");
                    } else {
                        $this.find("a").text(alltime + "s再次发送");
                    }

                }, 1000);
            })

            //发送短信验证码
            //function getCode(phone) {

            //    $.ajax({
            //        type: "post",
            //        url: '/Areas/Client/ZH/SJYZORYXYZ.ashx',
            //        data: { "action": "SJYZNew", "Phone": phone, "method": "dlyzsjh" },
            //        success: function (data) {
            //            if (data == 10) {
            //                easyDialog.open({
            //                    container: {
            //                        header: '温馨提示',
            //                        content: '手机号码参数错误'
            //                    },
            //                    autoClose: 3000
            //                });
            //            }
            //            else if (data == 0) {
            //                easyDialog.open({
            //                    container: {
            //                        header: '温馨提示',
            //                        content: '发送失败'
            //                    },
            //                    autoClose: 3000
            //                });
            //            }
            //            else if (data != null) {
            //                easyDialog.open({
            //                    container: {
            //                        header: '温馨提示',
            //                        content: '短信验证码已经发送至您的手机'
            //                    },
            //                    autoClose: 3000
            //                });

            //            }
            //            else if (data == 2) {

            //                easyDialog.open({
            //                    container: {
            //                        header: '温馨提示',
            //                        content: '短信已发送，请注意查收'
            //                    },
            //                    autoClose: 3000
            //                });
            //            }
            //            else {
            //                easyDialog.open({
            //                    container: {
            //                        header: '温馨提示',
            //                        content: '短信系统错误，发送失败'
            //                    },
            //                    autoClose: 3000
            //                });
            //            };
            //        },
            //        error: function (msg) {
            //            easyDialog.open({
            //                container: {
            //                    header: '温馨提示',
            //                    content: '短信系统错误，发送失败'
            //                },
            //                autoClose: 3000
            //            });
            //        }
            //    });
            //}
            //登陆成功
            function Register() {
                var phone = $.trim($("#telNum").val());
                var msgCode = $.trim($("#msgCode").val());

                if (phone.length != 11) {
                    easyDialog.open({
                        container: {
                            header: '温馨提示',
                            content: '请输入正确的手机号码'
                        },
                        autoClose: 3000
                    });
                    return;
                }
                if (msgCode.length == 0) {
                    easyDialog.open({
                        container: {
                            header: '温馨提示',
                            content: '请输入验证码'
                        },
                        autoClose: 3000
                    });
                    return;
                }
                $.ajax({
                    type: "post",
                    url: '/Areas/Client/ZH/HYLoginOrOut.ashx',
                    data: { "act": "LoginByPhone", "Phone": phone, "msgCode": msgCode },
                    success: function (data) {
                        if (data == -1) {
                            easyDialog.open({
                                container: {
                                    header: '温馨提示',
                                    content: '手机号码格式错误'
                                },
                                autoClose: 3000
                            });
                        } else if (data == 0) {
                            easyDialog.open({
                                container: {
                                    header: '温馨提示',
                                    content: '验证码错误'
                                },
                                autoClose: 3000
                            });

                        }
                        else if (data == -5) {
                            easyDialog.open({
                                container: {
                                    header: '温馨提示',
                                    content: '手机号与获取验证码的手机号必须相同'
                                },
                                autoClose: 3000
                            });

                        }
                        else if (data == -2) {
                            easyDialog.open({
                                container: {
                                    header: '温馨提示',
                                    content: '网络错误，请稍后再试'
                                },
                                autoClose: 3000
                            });
                        }
                        else {
                            easyDialog.open({
                                container: {
                                    header: '温馨提示',
                                    content: '登录成功！'
                                },
                                autoClose: 3000
                            });
                            if (('').length == 0) {
                                window.location.href = "/hy/index.html";
                            }
                            else {
                                window.location.href = '';
                            }
                        }
                    },
                    error: function (msg) {
                        easyDialog.open({
                            container: {
                                header: '温馨提示',
                                content: '短信系统错误，发送失败'
                            },
                            autoClose: 3000
                        });
                    }
                });
            }
            $(function () {
                //输入input框限制
                $(document).on("keydown paste", "input.onlynumber", function (event) {
                    var key = event.keyCode;
                    if (event.ctrlKey || event.shiftKey || event.altKey) { return false; }
                    if ((key < 48 || key > 57) && key != 8 && key != 37 && key != 39) { //键盘开放删除，和左右键
                        if (key < 96 || key > 105) //小键盘
                        {
                            return false;
                        }
                    }
                });
                $(document).on("keydown", "#HYZH,#HYMM", function (event) {
                    var key = event.keyCode;
                    if (key == 32) {    // 空格
                        return false;
                    }
                });
                $(document).on("keyup", ".mem_login input.telnum", function () {
                    var txtSJHM = $.trim($(this).val());
                    var reg = /^0{0,1}(13[0-9]|14[0-9]|15[0-9]|17[0-9]|18[0-9])[0-9]{8}$/;
                    if (reg.test(txtSJHM)) {
                        if (alltime == 60) {
                            $(this).parents("ul").find(".getvcode").addClass("active");
                        }

                    } else {
                        $(this).parents("ul").find(".getvcode").removeClass("active");
                    }
                });
                $(document).on("blur", ".mem_login input.telnum", function () {
                    $(".mem_login input.telnum").keyup();
                });
                $(".mem_login_title a").click(function () {
                    $(".error_message").css("display", "none");
                    var $this = $(this);
                    if ($this.hasClass("phonelogin")) {
                        $(this).html("手机验证码登录<span></span");
                        $this.removeClass("phonelogin"); $(this).parents(".mem_login_all").find("ul").eq(0).css("display", "block").siblings("ul").css("display", "none");
                    } else {
                        $(this).html("用户密码登录<span></span");

                        $this.addClass("phonelogin"); $(this).parents(".mem_login_all").find("ul").eq(1).css("display", "block").siblings("ul").css("display", "none");
                    }
                });
            });
        </script>

        @*<script>
    //判断是否登录
    $.ajax({
        url: "/Member/Base/isLogin?_=" + Math.random(),
        type: "get",
        datatype: "json",
        async: false,
        data: {},

        success: function (e) {
            var headHtml = "";
            var cartCount = '@ViewBag.cartCount';
            if (e.isLogin) {
                headHtml = "<a href='/0755/' class='index'><i></i>首页</a>" + "<a href='/hy/index.html'>" + e.user + "</a>" +
 "<a onclick=\"if (confirm('确认退出？')) {return true;}else{return false;}\"  href=\"/Areas/Client/ZH/HYLoginOrOut.ashx?act=logout\" rel=\"nofollow\">【退出】</a>" +
                        "<a href=\"/help/us_6.html\">预约流程</a>" +
                        "<a href='javascript:void();'>开放平台</a>" +
                        "<div class='contact'>" +
                        "<a href='http://kefu6.kuaishang.cn/bs/im.htm?cas=38582___670628&fi=42122'  target='_blank'>联系客服<i class='transition200'></i></a>" +
                        "<div class='contact_box'>" +
                            "<em></em>" +
                            "<h5><a href='javascript:void();'>检前咨询</a></h5>" +
                            "<ul class='clearfix'>" +
                                "<li><a href='http://kefu6.kuaishang.cn/bs/im.htm?cas=38582___670628&fi=42122' target='_blank'>咨询套餐</a></li>" +
                                "<li><a href='http://kefu6.kuaishang.cn/bs/im.htm?cas=38582___670628&fi=42122' target='_blank'>咨询预约</a></li>" +
                                "<li><a href='http://kefu6.kuaishang.cn/bs/im.htm?cas=38582___670628&fi=42122' target='_blank'>咨询报告</a></li>" +
                            "</ul>" +
                            "<h5><a href='javascript:void();'>帮助中心</a></h5>" +
                            "<ul class='clearfix'>" +
                                "<li><a href='/help/us_6.html'>预约流程</a></li>" +
                                "<li><a href='/help/us_8.html'>体检流程</a></li>" +
                                "<li><a href='/help/us_9.html'>退款政策</a></li>" +
                                "<li><a href='/help/us_10.html'>预约修改</a></li>" +
                                "<li><a href='/help/us_11.html'>检后服务</a></li>" +
                                "<li><a href='/help/us_7.html'>检前注意事项</a></li>" +
                            "</ul>" +
                            "<a class='btn transition200' href='http://kefu6.kuaishang.cn/bs/im.htm?cas=38582___670628&fi=42122'  target='_blank'>在线客服</a>" +
                            "<div class='phone'>400-1000-920</div>" +
                        "</div>" +
                        "</div>" +
                        "<a class='t_phone'>400-1000-920</a>";
            }
            else {
                headHtml = "<a href='/0755/' class='index'><i></i>首页</a>" +
                                        "<a onclick=\"javascript:void();\" href=\"/dl.html\" class='login'>您好！请登录</a>" +
                                        "<a href=\"/zc.html\" >注册</a>" +
                                        "<a href=\"/help/us_6.html\">预约流程</a>" +
                                        "<a href='javascript:void();'>开放平台</a>" +
                                        "<div class='contact'>" +
                                        "<a href='http://kefu6.kuaishang.cn/bs/im.htm?cas=38582___670628&fi=42122'  target='_blank'>联系客服<i class='transition200'></i></a>" +
                                        "<div class='contact_box'>" +
                                            "<em></em>" +
                                            "<h5><a href='javascript:void();'>检前咨询</a></h5>" +
                                            "<ul class='clearfix'>" +
                                                "<li><a href='http://kefu6.kuaishang.cn/bs/im.htm?cas=38582___670628&fi=42122' target='_blank'>咨询套餐</a></li>" +
                                                "<li><a href='http://kefu6.kuaishang.cn/bs/im.htm?cas=38582___670628&fi=42122' target='_blank'>咨询预约</a></li>" +
                                                "<li><a href='http://kefu6.kuaishang.cn/bs/im.htm?cas=38582___670628&fi=42122' target='_blank'>咨询报告</a></li>" +
                                            "</ul>" +
                                            "<h5><a href='javascript:void();'>帮助中心</a></h5>" +
                                            "<ul class='clearfix'>" +
                                                "<li><a href='/help/us_6.html'>预约流程</a></li>" +
                                                "<li><a href='/help/us_8.html'>体检流程</a></li>" +
                                                "<li><a href='/help/us_9.html'>退款政策</a></li>" +
                                                "<li><a href='/help/us_10.html'>预约修改</a></li>" +
                                                "<li><a href='/help/us_11.html'>检后服务</a></li>" +
                                                "<li><a href='/help/us_7.html'>检前注意事项</a></li>" +
                                            "</ul>" +
                                            "<a class='btn transition200' href='http://kefu6.kuaishang.cn/bs/im.htm?cas=38582___670628&fi=42122'  target='_blank'>在线客服</a>" +
                                            "<div class='phone'>400-1000-920</div>" +
                                        "</div>" +
                                        "</div>" +
                                        "<a class='t_phone'>400-1000-920</a>";
            }

            $(".topbanner_right").html(headHtml);
        }
    });
</script>*@

<script type="text/javascript">
    $(function () {
        var msgNo = $("#msgNo");
        msgNo.hide();
        $("#getCode").click(function () {
            msgNo.hide();

            var phone = $("#phone").val();
            if (phone != null && phone.length > 0) {
                $.ajax({
                    url: '@Url.Action("GetSecurityCode", "Mobile")',
                    type: 'post',
                    data: { phone: phone },
                    success: function (data) {
                        if (data.Code == 1) {
                            $("#code").val(data.Data);
                        }
                    }
                });
            }
            else {
                msgNo.html("请输入手机号码！");
                msgNo.show();
            }
        });

        $("#nameLogin").click(function () {
            msgNo.hide();
            var name = $("#name").val();
            var pwd = $("#pwd").val();
            var ReturnUrl = $.request.queryString["ReturnUrl"];

            $.ajax({
                url: '@Url.Action("NameLogin", "Mobile")',
                type: 'post',
                data: { name: name, pwd: pwd, ReturnUrl: ReturnUrl },
                success: function (data) {
                    if (data.Code == 1) {
                        if (data.Data)
                            {
                                window.location.href = data.Data;
                            }
                            else
                            {
                                window.location.href = '@Url.Action("Index", "Mobile")';
                            }
                    }
                    else {
                        msgNo.html(data.Msg);
                        msgNo.show();
                    }
                }
            });

        });
        $("#phoneLogin").click(function () {
            msgNo.hide();
            var phone = $("#phone").val();
            var code = $("#code").val();
            //var ReturnUrl = $.request.queryString["ReturnUrl"];
            $.ajax({
                url: '@Url.Action("PhoneLogin", "Mobile")',
                type: 'post',
                data: { phone: phone, code: code, ReturnUrl: "" },
                success: function (data) {
                    if (data.Code == 1) {
                        if (data.Data) {
                            window.location.href = '@Url.Action("Index", "Home")';
                        }
                        else {
                            window.location.href = '@Url.Action("Index", "Home")';
                        }
                    }
                    else {
                        msgNo.html(data.Msg);
                        msgNo.show();
                    }
                }
            });
        });
    });
</script>

